home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 18 / 018.d81 / pps #40 < prev    next >
Text File  |  2022-08-26  |  3KB  |  193 lines

  1. ======================================
  2.     PEEKs, POKEs & SYSes, Part 40
  3.  
  4.     by Jim Weiler and Alan Gardner
  5. ======================================
  6.  
  7.      SOUND ON THE COMMODORE 64
  8.      -------------------------
  9.  
  10.   This month we will begin to learn
  11.  
  12. how to make beautiful noises emanate
  13.  
  14. from our Commodore 64s.  Now, don't
  15.  
  16. get all wild and frantic thinking
  17.  
  18. you'll be making music right away.
  19.  
  20. There are a lot of piddly details
  21.  
  22. involved in making Commodore 64
  23.  
  24. sound, and you have to know quite a
  25.  
  26. number of them before you can make
  27.  
  28. even the merest peep sound the way
  29.  
  30. you want it to.
  31.  
  32.   We will cover ALL of those piddly
  33.  
  34. details in the coming months, delving
  35.  
  36. deeply into theories we never even
  37.  
  38. knew existed.  With each installment
  39.  
  40. our knowledge will become more
  41.  
  42. complete until we know as much as the
  43.  
  44. pros think they do.
  45.  
  46.   Enough big talk.  Let's learn
  47.  
  48. something.
  49.  
  50.                 ---
  51.                 SID
  52.                 ---
  53.  
  54.   SID stands for Sound Interface
  55.  
  56. Device.  The SID is a single
  57.  
  58. integrated circuit that generates all
  59.  
  60. the sounds your Commodore makes.
  61.  
  62. Everything we learn about sound will
  63.  
  64. be based on the way SID works, so
  65.  
  66. let's start by looking briefly at how
  67.  
  68. we can talk to SID.
  69.  
  70.   SID is always busy, even when
  71.  
  72. your computer isn't making a sound.
  73.  
  74. He's always checking 29 addresses to
  75.  
  76. see if there's anything for him to
  77.  
  78. do.  SID makes noises based entirely
  79.  
  80. on what he finds in those addresses.
  81.  
  82. When you turn your computer on, those
  83.  
  84. addresses are set up to tell SID not
  85.  
  86. to make a peep.  He keeps doing that
  87.  
  88. until you or your programs put values
  89.  
  90. in those addresses that say 'Start
  91.  
  92. Peeping'.
  93.  
  94.   In fact, every sound your Commodore
  95.  
  96. has ever made (except gross physical
  97.  
  98. ones like the time you dropped it on
  99.  
  100. the floor) was made by SID following
  101.  
  102. instructions he found in his 29
  103.  
  104. address locations.  Our coverage of
  105.  
  106. Commodore sound will deal almost
  107.  
  108. exclusively with the theory and
  109.  
  110. practice of putting the right data
  111.  
  112. into SID's addresses.
  113.  
  114.   Oh yes, those addresses start at
  115.  
  116. 54272.  In most discussions from now
  117.  
  118. on I will set S=54272 and then use
  119.  
  120. offsets such as S+7 or S+24 to
  121.  
  122. indicate which SID address I am
  123.  
  124. using.
  125.  
  126.          ------------------
  127.          LET'S MAKE A NOISE
  128.          ------------------
  129.  
  130.   There's not a lot involved in
  131.  
  132. making SID make a noise.  Let's
  133.  
  134. see...  You need to decide how loud to
  135.  
  136. make it.  Then you need to know what
  137.  
  138. pitch to use.  You also need to know
  139.  
  140. what waveform and envelope to use.
  141.  
  142. (That's about like choosing an
  143.  
  144. instrument.) SID has three distinct
  145.  
  146. "voices" so you need to decide which
  147.  
  148. one to use.  (They're all the same, so
  149.  
  150. it doesn't really matter which you
  151.  
  152. choose.)  Finally, you need to decide
  153.  
  154. how long to make the noise.
  155.  
  156.   Volume is one POKE.  Pitch is two
  157.  
  158. more.  Envelope takes two pokes, and
  159.  
  160. the waveform takes at least one to
  161.  
  162. turn the sound on and another to turn
  163.  
  164. it off.  And you need some kind of a
  165.  
  166. delay loop for duration.
  167.  
  168.   Here's an example of a simple
  169.  
  170. C-sharp tone.
  171.  
  172. S = 54272
  173. POKE S+0,85:POKE S+1,36 (c-sharp)
  174. POKE S+24,15            (volume)
  175. POKE S+5,9:POKE S+6,0   (envelope)
  176. POKE S+4,33             (play it)
  177. FOR A=1 TO 200: NEXT    (delay)
  178. POKE S+4,32             (stop it)
  179.  
  180.   You really can't make a satisfactory
  181.  
  182. sound on your own until you understand
  183.  
  184. envelope, waveform, volume, pitch, and
  185.  
  186. voice.  So take a deep breath and
  187.  
  188. prepare for some heavy doses of
  189.  
  190. technical exposition.
  191.                     
  192. ------< continued in Part 41 >--------
  193.